package com.lihaogn.sell.service.impl;

import com.lihaogn.sell.dto.SaleroomDto;
import com.lihaogn.sell.dto.SaleroomGraphDto;
import com.lihaogn.sell.dto.TopSaleDto;
import com.lihaogn.sell.mapper.WelcomeMapper;
import com.lihaogn.sell.service.WelcomeService;
import com.lihaogn.sell.vo.IndexVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * fileName: WelcomeServiceImpl
 * description: ...
 *
 * @author lihaogn-main
 * @version 1.0
 * @date 2019/12/20 11:29
 */
@Service
public class WelcomeServiceImpl implements WelcomeService {

    @Autowired
    WelcomeMapper welcomeMapper;

    @Override
    public IndexVo getWelcomData() {

        IndexVo indexVo = new IndexVo();

        SaleroomDto daySaleroomDto = welcomeMapper.querySalesByDay();
        SaleroomDto weekSaleroomDto = welcomeMapper.querySalesByWeek();
        SaleroomDto monthSaleroomDto = welcomeMapper.querySalesByMonth();

        List<TopSaleDto> topsByDay = welcomeMapper.queryTopsByDay();
        List<TopSaleDto> topsByWeek = welcomeMapper.queryTopsByWeek();
        List<TopSaleDto> topsByMonth = welcomeMapper.queryTopsByMonth();

        List<SaleroomGraphDto> saleForGraphByWeek = welcomeMapper.querySaleForGraphByWeek();
        List<SaleroomGraphDto> saleForGraphByMonth = welcomeMapper.querySaleForGraphByMonth();

        indexVo.setDaySaleroom(daySaleroomDto);
        indexVo.setWeekSaleroom(weekSaleroomDto);
        indexVo.setMonthSaleroom(monthSaleroomDto);

        indexVo.setDayTops(topsByDay);
        indexVo.setWeekTops(topsByWeek);
        indexVo.setMonthTops(topsByMonth);

        indexVo.setWeekSaleGraph(saleForGraphByWeek);
        indexVo.setMonthSaleGraph(saleForGraphByMonth);

        return indexVo;
    }
}
